﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using T2.WebSecurity.Business.Entities.Interfaces;
using T2.WebSecurity.Business.Entities.Search.Interfaces;
using T2.WebSecurity.Business.Entities.Search;

namespace T2.WebSecurity.Business.Workflow.Activities.Db.UserProfile
{

    public sealed class UserProfile_AddCodeActivity : CodeActivity
    {
        public InArgument<string> UserName { get; set; }
        public InArgument<IBusinessService> BusinessService { get; set; }
        public OutArgument<IUserProfile_biz> Result { get; set; }
     
        protected override void Execute(CodeActivityContext context)
        {
            IBusinessService businessService = context.GetValue(this.BusinessService);
            string userName = context.GetValue(this.UserName);

            IUserProfileSearch_biz param = new UserProfileSearch_biz();
            param.Action = "Search";
            param.UserName = userName;
            param.SortType = "asc";
            param.SortColumn = "UserId";
            param.PageNumber = 1;
            param.PageSize = 10;

            List<IUserProfile_biz> users = businessService.UserProfileController_Search(param,false,false);

            context.SetValue(Result, users.FirstOrDefault());
        }


    }
}
